

export let formats = {
    formatDate
}

function formatDate(date) {
    let newDate = new Date(date);
    let year = newDate.getFullYear();
    let month = zero(newDate.getMonth() + 1);//0-11
    let day = zero(newDate.getDate());//1-31
    let hour = zero(newDate.getHours());
    let minute = zero(newDate.getMinutes());
    let second = zero(newDate.getSeconds());
    return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
}

function zero(n) {
    return n > 9 ? n : '0' + n
}